package com.annotation;

import java.lang.reflect.Field;

public class FruitInfoUtil {
    public static void getFruitInfo(Class<?> clazz){
        String strFruitProvder = "供应商信息";
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            if(field.isAnnotationPresent(FruitProvider.class)){
                FruitProvider fruitProvider = (FruitProvider) field.getAnnotation(FruitProvider.class);
                strFruitProvder = "供应商编号：" + fruitProvider.id() + "，供应商名称：" + fruitProvider.name() + "，供应商地址：" + fruitProvider.address();
                System.out.println(strFruitProvder);
            }
        }
    }

    public static void main(String[] args) {
        getFruitInfo(Apple.class);
    }
}
